home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / Translation.p < prev    next >
Encoding:
Text File  |  1997-08-12  |  12.0 KB  |  311 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        Translation.p
  3.  
  4.      Contains:    Translation Manager (Macintosh Easy Open) Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1991-1997 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT Translation;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __TRANSLATION__}
  28. {$SETC __TRANSLATION__ := 1}
  29.  
  30. {$I+}
  31. {$SETC TranslationIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __FILES__}
  38. {$I Files.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __COMPONENTS__}
  41. {$I Components.p}
  42. {$ENDC}
  43. {$IFC UNDEFINED __TRANSLATIONEXTENSIONS__}
  44. {$I TranslationExtensions.p}
  45. {$ENDC}
  46.  
  47.  
  48. {$PUSH}
  49. {$ALIGN MAC68K}
  50. {$LibExport+}
  51.  
  52. {  enumerated types on how a document can be opened }
  53.  
  54. TYPE
  55.     DocOpenMethod                        = INTEGER;
  56.  
  57. CONST
  58.     domCannot                    = 0;
  59.     domNative                    = 1;
  60.     domTranslateFirst            = 2;
  61.     domWildcard                    = 3;
  62.  
  63. {  0L terminated array of OSTypes, or FileTypes }
  64.  
  65. TYPE
  66.     TypesBlock                            = ARRAY [0..63] OF OSType;
  67.     TypesBlockPtr                        = ^OSType;
  68. {  Progress dialog resource ID }
  69.  
  70. CONST
  71.     kTranslationScrapProgressDialogID = -16555;
  72.  
  73. {  block of data that describes how to translate }
  74.  
  75. TYPE
  76.     FileTranslationSpecPtr = ^FileTranslationSpec;
  77.     FileTranslationSpec = RECORD
  78.         componentSignature:        OSType;
  79.         translationSystemInfo:    Ptr;
  80.         src:                    FileTypeSpec;
  81.         dst:                    FileTypeSpec;
  82.     END;
  83.  
  84.     FileTranslationSpecArrayPtr            = ^FileTranslationSpec;
  85. {****************************************************************************************
  86. *   GetFileTypesThatAppCanNativelyOpen
  87. *  This routine returns a list of all FileTypes that an application can open by itself
  88. *  Enter:    appVRefNumHint        volume where application resides (can be wrong, and if is, will be used as a starting point)
  89. *             appSignature        signature (creator) of application
  90. *             nativeTypes            pointer to a buffer to be filled with up to 64 FileTypes
  91. *  Exit:    nativeTypes            zero terminated array of FileTypes that can be opened by app
  92. }
  93. FUNCTION GetFileTypesThatAppCanNativelyOpen(appVRefNumHint: INTEGER; appSignature: OSType; VAR nativeTypes: FileType): OSErr;
  94.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  95.     INLINE $701C, $ABFC;
  96.     {$ENDC}
  97. {****************************************************************************************
  98. *  ExtendFileTypeList
  99. *  This routine makes a new list of file types that can be translated into a type in the given list
  100. *  Used by StandardFile
  101. *  Enter:    originalTypeList        pointer to list of file types that can be opened
  102. *             numberOriginalTypes        number of file types in orgTypeList
  103. *              extendedTypeList        pointer to a buffer to be filled with file types
  104. *             numberExtendedTypes        max number of file types that can be put in extendedTypeList
  105. *  Exit:    extendedTypeList        buffer filled in with file types that can be translated
  106. *             numberExtendedTypes        number of file types put in extendedTypeList
  107. }
  108. FUNCTION ExtendFileTypeList({CONST}VAR originalTypeList: FileType; numberOriginalTypes: INTEGER; VAR extendedTypeList: FileType; VAR numberExtendedTypes: INTEGER): OSErr;
  109.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  110.     INLINE $7009, $ABFC;
  111.     {$ENDC}
  112.  
  113. {****************************************************************************************
  114. *  This routine checks if a file can be opened by a particular application.
  115. *  If so, it returns if it needs to be translated first, and if so then how.
  116. *  The FileTypes that the app can open are specified by nativelyOpenableTypes,
  117. *  or if it is NULL, GetFileTypesThatAppCanNativelyOpen is called.
  118. *  Enter:    targetDocument        document to check if it can be opened
  119. *             appVRefNumHint        vRefNum of application to open doc ( can be wrong, and if is, will be used as a starting point)
  120. *             appSignature        signature (creator) of application to open doc
  121. *             nativeTypes            zero terminated list of FileTypes app can open natively, or NULL to use default list
  122. *             onlyNative            whether to consider if document can be translated before opening
  123. *             howToOpen            pointer to buffer in which to put how the document can be opened
  124. *             howToTranslate        pointer to buffer in which to put a FileTranslationSpec record
  125. *  Exit:    howToOpen            whether file needs to be translated to be read
  126. *             howToTranslate        if file can be translated, buffer filled in with how to translate
  127. *             returns                noErr, noPrefAppErr
  128. }
  129. FUNCTION CanDocBeOpened({CONST}VAR targetDocument: FSSpec; appVRefNumHint: INTEGER; appSignature: OSType; {CONST}VAR nativeTypes: FileType; onlyNative: BOOLEAN; VAR howToOpen: DocOpenMethod; VAR howToTranslate: FileTranslationSpec): OSErr;
  130.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  131.     INLINE $701E, $ABFC;
  132.     {$ENDC}
  133.  
  134. {****************************************************************************************
  135. *  GetFileTranslationPaths
  136. *  This routine returns a list of all ways a translation can occure to or from a FileType.
  137. *  The app is checked to exist.  The hint for each app is the VRefNum and DTRefNum
  138. *  Enter:    srcDoc            source file or NULL for all matches
  139. *             dstDoc            destination FileType or NULL for all matches
  140. *             maxResultCount
  141. *             resultBuffer
  142. *  Exit:    number of paths
  143. }
  144. FUNCTION GetFileTranslationPaths(VAR srcDocument: FSSpec; dstDocType: FileType; maxResultCount: INTEGER; resultBuffer: FileTranslationSpecArrayPtr): INTEGER;
  145.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  146.     INLINE $7038, $ABFC;
  147.     {$ENDC}
  148. {****************************************************************************************
  149. *  GetPathFromTranslationDialog
  150. *  This routine, with a given document, application, and a passed typelist will display the
  151. *  Macintosh Easy Open translation dialog allowing the user to make a choice.  The choice
  152. *  made will be written as a preference (so the next call to CanDocBeOpened() will work).
  153. *  The routine returns the translation path information.
  154. *  Enter:    theDocument            FSSpec to document to open
  155. *             theApplication        FSSpec to application to open document
  156. *             typeList            Nil terminated list of FileType's (e.g. SFTypeList-like) of types
  157. *                                 you would like the documented translated to.  Order most perferred
  158. *                                 to least.
  159. *  Exit:    howToOpen            Translation method needed to open document
  160. *             howToTranslate        Translation specification
  161. *             returns                Any errors that might occur.
  162. }
  163. FUNCTION GetPathFromTranslationDialog({CONST}VAR theDocument: FSSpec; {CONST}VAR theApplication: FSSpec; typeList: TypesBlockPtr; VAR howToOpen: DocOpenMethod; VAR howToTranslate: FileTranslationSpec): OSErr;
  164.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  165.     INLINE $7037, $ABFC;
  166.     {$ENDC}
  167.  
  168. {****************************************************************************************
  169. *   TranslateFile
  170. *  This routine reads a file of one format and writes it to another file in another format. 
  171. *  The information on how to translated is generated by the routine CanDocBeOpened.
  172. *  TranslateFile calls through to the TranslateFile Extension's DoTranslateFile routine.  
  173. *  The destination file must not exist.  It is created by this routine.  
  174. *  Enter:    sourceDocument            input file to translate
  175. *             destinationDocument        output file of translation
  176. *             howToTranslate            pointer to info on how to translate
  177. *  Exit:    returns                    noErr, badTranslationSpecErr 
  178. }
  179. FUNCTION TranslateFile({CONST}VAR sourceDocument: FSSpec; {CONST}VAR destinationDocument: FSSpec; {CONST}VAR howToTranslate: FileTranslationSpec): OSErr;
  180.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  181.     INLINE $700C, $ABFC;
  182.     {$ENDC}
  183. {****************************************************************************************
  184. *   GetDocumentKindString
  185. *  This routine returns the string the Finder should show for the "kind" of a document
  186. *  in the GetInfo window and in the kind column of a list view.  
  187. *  Enter:    docVRefNum        The volume containing the document
  188. *             docType            The catInfo.fdType of the document
  189. *             docCreator        The catInfo.fdCreator of the document
  190. *             kindString        pointer to where to return the string
  191. *  Exit:    kindString        pascal string.  Ex: "\pSurfCalc spreadsheet"
  192. *             returns            noErr, or afpItemNoFound if kind could not be determined
  193. }
  194. FUNCTION GetDocumentKindString(docVRefNum: INTEGER; docType: OSType; docCreator: OSType; VAR kindString: Str63): OSErr;
  195.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  196.     INLINE $7016, $ABFC;
  197.     {$ENDC}
  198. {****************************************************************************************
  199. *  GetTranslationExtensionName
  200. *  This routine returns the translation system name from a specified TranslationSpec
  201. *  Enter:    translationMethod    The translation path to get the translation name from
  202. *  Exit:    extensionName        The name of the translation system
  203. *             returns                Any errors that might occur
  204. }
  205. FUNCTION GetTranslationExtensionName({CONST}VAR translationMethod: FileTranslationSpec; VAR extensionName: Str31): OSErr;
  206.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  207.     INLINE $7036, $ABFC;
  208.     {$ENDC}
  209.  
  210. {****************************************************************************************
  211. *  GetScrapDataProcPtr
  212. *  This is a prototype for the function you must supply to TranslateScrap. It is called to 
  213. *  get the data to be translated.  The first call TranslateScrap will make to this is to
  214. *  ask for the 'fmts' data.  That is a special.   You should resize and fill in the handle
  215. *  with a list all the formats that you have available to be translated, and the length of each.
  216. *  (See I.M. VI 4-23 for details of 'fmts').  It will then be called again asking for one of  
  217. *  the formats that 'fmts' list said was available.
  218. *  Enter:    requestedFormat            Format of data that TranslateScrap needs.
  219. *             dataH                    Handle in which to put the requested data
  220. *             srcDataGetterRefCon        Extra parameter for you passed to TranslateScrap
  221. *             
  222. *  Exit:    dataH                    Handle is resized and filled with data in requested format
  223. }
  224.  
  225. TYPE
  226.     GetScrapDataProcPtr = ProcPtr;  { FUNCTION GetScrapData(requestedFormat: ScrapType; dataH: Handle; srcDataGetterRefCon: UNIV Ptr): OSErr; }
  227.  
  228.     GetScrapDataUPP = UniversalProcPtr;
  229.  
  230. CONST
  231.     uppGetScrapDataProcInfo = $00000FE0;
  232.  
  233. FUNCTION NewGetScrapDataProc(userRoutine: GetScrapDataProcPtr): GetScrapDataUPP;
  234.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  235.     INLINE $2E9F;
  236.     {$ENDC}
  237.  
  238. FUNCTION CallGetScrapDataProc(requestedFormat: ScrapType; dataH: Handle; srcDataGetterRefCon: UNIV Ptr; userRoutine: GetScrapDataUPP): OSErr;
  239.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  240.     INLINE $205F, $4E90;
  241.     {$ENDC}
  242.  
  243. TYPE
  244.     GetScrapData                        = GetScrapDataUPP;
  245. {****************************************************************************************
  246. *  TranslateScrap
  247. *  This routine resizes the destination handle and fills it with data of the requested format.
  248. *  The data is generated by translated one or more source formats of data supplied by
  249. *  the procedure srcDataGetter.  
  250. *  This routine is automatically called by GetScrap and ReadEdition.  You only need to call
  251. *  this if you need to translated scrap style data, but are not using the ScrapMgr or EditionMgr.
  252. *  Enter:    sourceDataGetter            Pointer to routine that can get src data
  253. *             sourceDataGetterRefCon        Extra parameter for dataGetter
  254. *             destinationFormat            Format of data desired
  255. *             destinationData                Handle in which to store translated data
  256. *             
  257. *  Exit:    dstData                        Handle is resized and filled with data in requested format
  258. }
  259. FUNCTION TranslateScrap(sourceDataGetter: GetScrapData; sourceDataGetterRefCon: UNIV Ptr; destinationFormat: ScrapType; destinationData: Handle; progressDialogID: INTEGER): OSErr;
  260.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  261.     INLINE $700E, $ABFC;
  262.     {$ENDC}
  263.  
  264.  
  265. {$ALIGN RESET}
  266. {$POP}
  267.  
  268. {$SETC UsingIncludes := TranslationIncludes}
  269.  
  270. {$ENDC} {__TRANSLATION__}
  271.  
  272. {$IFC NOT UsingIncludes}
  273.  END.
  274. {$ENDC}
  275.